package com.jason.canvas.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

/**
 * @DESC: path的arcTo的使用
 * @Author: Jason
 * @Date: 16/9/19
 * @Time: 11:32
 */

public class PathArcTo8 extends View {

    private Paint mPaint;
    private Path mPath;

    public PathArcTo8(Context context, AttributeSet attrs) {
        super(context, attrs);

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setColor(Color.CYAN);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeWidth(10);

        mPath = new Path();
        mPath.moveTo(100, 100);
        // 连接路径到点
        RectF oval = new RectF(100, 100, 200, 200);
        // 生成弧线
        //mPath.arcTo(oval, 0, 90);
        /**
         * 虽然使用arcTo绘制的是一段弧 但其最终都会与我们的起始点[100,100]链接起来
         * 如果不想连接,强制让arcTo绘制的起点作为Path的起点
         */
        mPath.arcTo(oval, 0, 90, true);



    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.drawPath(mPath, mPaint);
    }
}
